package com.zhang.sql;

import org.apache.flink.table.functions.AggregateFunction;

/**
 * @title: 自定义UDAF 求最大值
 * @author: zhang
 * @date: 2022/2/15 21:20
 */
public class MaxFunc_UDAF extends AggregateFunction<Long, AccMax> {




    @Override
    public Long getValue(AccMax accumulator) {
        return accumulator.acc;
    }

    @Override
    public AccMax createAccumulator() {
        return new AccMax(0L);
    }


    public void accumulate(AccMax accMax, Long num) {
        accMax.acc = Math.max(accMax.acc, num);
    }
}


